package com.briup.smartlabs.web.controller;

import java.util.Date;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.briup.smartlabs.bean.ex.SysLog;
import com.briup.smartlabs.common.utils.Response;
import com.briup.smartlabs.service.SysLogService;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.swagger.web.ApiResourceController;

@Api(tags = "系统日志服务")
@RestController
@RequestMapping("/syslog")
@RequiredArgsConstructor
public class SysLogController {

    private final SysLogService sysLogService;

    @ApiOperation("分页条件查询")
    @GetMapping("/by/condition")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前页", dataType = "int", required = true, defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "int", required = true, defaultValue = "5"),
            @ApiImplicitParam(name = "begin", value = "开始时间",paramType = " query", dataType = " String"),
            @ApiImplicitParam(name = "end", value = "结束时间", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "key", value = "用户操作", paramType = "query", dataType = "String")
    })
    public Response<PageInfo<SysLog>> findByCondition(
            int pageNum,
            int pageSize,
            @DateTimeFormat(pattern = "yyyy-MM-dd") Date begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd") Date end,
            String key) {
        PageInfo<SysLog> pageInfo =
                sysLogService.findByCondition(pageNum, pageSize, begin, end, key);
        return Response.ok(pageInfo);
    }

}








